
/* Dear user: At least PARI-GP 2.10 is required for this script 

  Please browse into the end of this file, for the motivation of this script. */

/* R. J. Cano, Mar 16 2018 */

\\ Yet another alternative (potentially faster) way of calculation for G(n);

G_alt(n)=sum(k=1,n-1,k*(n-k)*(n+1)^(2*k))+sum(i=1,n,sum(j=0,i-1,i*(n-j)*(n+1)^(i+j)))+sum(j=2,n-1,sum(i=1,j-1,i*(n-j)*(n+1)^(i+j)))+1;

/* R. J. Cano, Mar 15 2018 */

\\ Finding the least squarefree k such that n+k is 0 ( mod (n+1)^2 ); [param. match_g=0; rank=0; below]
\\ Finding the least nth squarefree number k (from the least descirbed above, onward) such that n+k is 0 ( mod (n+1)^2 ); [param. match_g=0; rank=1; below]
\\ Finding the rank for the squarefree number g(n), which satisfies n+g(n) is 0 ( mod (n+1)^2 ); [param. match_g=1; rank=any; below]

guessLeastTerms({upTo=2^25},{rank=0},{match_g=0})={
  my( T:list=List(), n=0, u=0, y=1, r=!!rank );
  forsquarefree(k=1,upTo,
    if(!match_g,
      if(r,rank=n);
      if(!((n+k[1])%((n+1)^2)),
        if(u==rank,n++;u=0;listput(T,k[1])
        ,u++;
        )
      )
    ,if(k[1]==y,n++;y=g(n);listput(T,u));u++; /* 1 included as the zeroth squarefree number in the resulting list of indices. */
    )
  );
  return(T);
}

/* Is it already present at OEIS ? (See below first 33 terms):
 
 1, 3, 7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273, 307, 1065, 1181, 1303, 1915, 2094, 2281, 3101, 3355, 3619, 3893, 4177, 4471, 6697, 8161, 9769, ...
 
   And btw, what about this other one. Is it present? (See below first 12 terms):
   
 1, 7, 61, 141, 321, 535, 1121, 1657, 2503, 3791, 5798, 7621
 
   And yet this other? (See below first 6 terms): 

 0, 2, 65, 3743, 345557, 50782174

 None of these in the precise terms shown above are already part of the OEIS up to present revision of this script.
 
 */

/* R. J. Cano, Mar 05 2018,

 On the possibility of having a squarefree g(n) for every n>0;

*/

f0(n)=sum(k=0,n,   k  *(n+1)^k); \\ Greatest permutation that can be written in the base n+1 without repetition of digits (Essentially matching terms with A062813).
f1(n)=sum(k=0,n,(n-k) *(n+1)^k); \\ Smallest permutation that can be written in the base n+1 without repetition of digits (Essentially matching terms with A023811). 

g(n)=1+f0(n)*f1(n); \\ Def. inspired by Euclid's idea on getting new primes based upon "all those already known"...

\\ Decomposition of g(n) in parts p0, p1, and p2, according to an application of the delta-no-delta formalism.

p0(n)=sum(t=1,n-1,t*(n-t)*((n+1)^2)^(t-1)); \\ Here are the same digits found in the palindromes defining A211869, this time in the base (n+1)^2;

p1(n)=sum(i=1,n-1,sum(k=i+1,n,i*(n-k)*((n+1)^(i+k))));

p2(n)=sum(k=0,n-1,sum(i=k+1,n,i*(n-k)*((n+1)^(i+k))));

/*
 -----------------------------------
  n+g(n) is a multiple of (n+1)^2  
 -----------------------------------
 Proof: If we notice above that i+k always range for p2(n) between 1 and 2*n-1, such affirmation depends on the p2(n) term where (k,i)=(0,1) because for any other combination and due the properties of powers, at least (n+1)^2 always is factorizable from the remaining expression. But then what left there is n*(n+1)+1=(n+1)^2-n, revealing that n+g(n) is 0 mod (n+1)^2 */ 

H(n)=((n+1)^2)*p0(n);

G(n)=1+H(n)+p1(n)+p2(n); \\ Equivalent to g(n) built from the previous decomposition;

Q(n)=(g(n)+n)/((n+1)^2);

/* WHY ALL THIS ?
   === --- ==== -
 
(Topic #20, SeqFan Digest, Vol 114, Issue 4, Date: 16 March 2018 at GMT 18:02)

On squarefree numbers sequences obtained by operating with permutations.

Dear Seqfan,

I'm interested on figuring out how to prove that: IF it is given a mapping between nonnegative integers "g : N U {0} ---> S" ( where S is a subset of N U {0} ), THEN the fact of having an explicit (polynomial) formula for g(n) such that "n+g(n)= 0 (mod) (n+1)^2" is a sufficient condition for ensuring that g(n) is squarefree for n>0;

Could someone give some advise in this matter?

At purpose, as an example candidate for such kind of function g(n), please consider: g(n)=1+A062813(n+1)*A023811(n+1); Briefly, a particular case could be n=9, there: n+1=10; A062813(10)=9876543210; and A023811(10)=123456789; So: g(9)= 1219326311126352700 ( which of course is 0 mod 100 )

Also as a related issue and a more simple sequence than the one proposed here initially, we could ask for: "Least integer k such that k is squarefree and n+k is 0 mod (n+1)^2"; ... well, this other sequence prepended by an 1 match its first eighteen terms with A002061 (http://oeis.org/A002061) where the 19th term is 343=7^3 whereas it would be expected 1065; Indeed the first 33 terms are: 1, 3, 7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273, 307, [1065], 1181, 1303, 1915, 2094, 2281, 3101, 3355, 3619, 3893, 4177, 4471, 6697, 8161, 9769, ...; And this last one is not already present in the OEIS  (Note: There 1 was interpreted as the zeroth squarefree number when sequencing that).

Many thanks in advance!

____________________________

R. J. Cano
1-43 Entrada principal a Santa Juana. Mrida, ME 5101, Venezuela
Phone: +58 412 077 6 077;

End.*/
